package com.gy.api.mobile.app;

import com.gy.api.base.ApiIndex;
import com.gy.api.base.IDEntity;
import com.gy.api.base.R;
import com.gy.api.pc.clap.domain.vo.CulvertDetailVO;
import com.gy.api.pc.clap.domain.vo.CulvertDto;
import com.gy.api.pc.clap.domain.vo.CulvertExcelVo;
import com.gy.api.pc.clap.service.IAssociationClapCulvertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.rmi.ServerException;
import java.util.List;


@RestController
@RequestMapping("/app/association/clap/culvert")
@Api( tags = ApiIndex.AppAssociationClapCulvertController)
public class AppAssociationClapCulvertController  {

    @Autowired
    IAssociationClapCulvertService associationClapCulvertService;



    @PostMapping("/saveAndCommit")
    @ApiOperation(value = "协拍涵保存并提交---手机端")
    public R saveAndCommit(@RequestBody CulvertDto dto) throws Exception {
         associationClapCulvertService.saveAndCommit(dto);
        return new R();
    }

    @GetMapping("/detail")
    @ApiOperation(value = "协拍涵详情---手机端")
    public R<CulvertDetailVO> detailCulvert(@RequestParam String id) throws ServerException {
        CulvertDetailVO vo = associationClapCulvertService.detailCulvert(id);
        return new R(vo);
    }

    @PostMapping("/del")
    @ApiOperation(value = "协拍涵删除---手机端")
    public R delCulvert(@RequestBody IDEntity id) throws ServerException {
        associationClapCulvertService.delCulvert(id.getId());
        return new R().setMessage("协拍涵删除成功");
    }

//    @PostMapping("/notice/page")
//    @ApiOperation(value = "协拍涵公示列表")
//    public AjaxResult<Page<PageCulvertNoticeVo>> pagePublicityCulvert(@RequestBody PageCulvertNoticeDto dto) {
//        Page<PageCulvertNoticeVo> page = associationClapCulvertService.pagePublicityCulvert(dto);
//        return AjaxResult.success(page);
//    }
//
//    @GetMapping("/notice/detail")
//    @ApiOperation(value = "协拍涵公示详情")
//    public AjaxResult<CulvertNoticeDetailVo> noticeDetail(@ApiParam(value = "协拍涵ID", required = true)
//                                                              @RequestParam Long id) {
//        CulvertNoticeDetailVo vo = associationClapCulvertService.noticeDetail(id);
//        return AjaxResult.success(vo);
//    }
//
//
    @PostMapping("/import")
    @ApiOperation(value = "协拍涵-场景数据excel导入-返回列表")
    public  R<List<CulvertExcelVo>> importCert(@RequestPart("file") MultipartFile file, HttpServletRequest request) throws Exception {
        List<CulvertExcelVo> vos=  associationClapCulvertService.importCert(file,request);
        return new R(vos);
    }
}

